package com.sinvo.oa.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sinvo.oa.entity.model.system.SysLoginLog;
import com.sinvo.oa.entity.vo.system.SysLoginLogQueryVo;
import com.sinvo.oa.result.R;
import com.sinvo.oa.service.SysLoginLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 登录日志控制器
 */
@Api(tags = "登录日志管理接口")
@RestController
@RequestMapping("admin/system/sysLoginLog")
public class SysLoginLogController {

    @Autowired
    private SysLoginLogService sysLoginLogService;

    /**
     * 条件分页查询
     *
     * @param pageNum            当前页
     * @param pageSize           页大小
     * @param sysLoginLogQueryVo username begin/end
     * @return R
     */
    @PreAuthorize("hasAuthority('btn.sysLoginLog.list')")
    @ApiOperation(value = "条件分页查询")
    @GetMapping("{pageNum}/{pageSize}")
    public R pageQueryLoginLog(@PathVariable Long pageNum,
                           @PathVariable Long pageSize,
                           SysLoginLogQueryVo sysLoginLogQueryVo) {
        //pageNum 当前页  pageSize 每页显示记录数
        Page<SysLoginLog> page = new Page<>(pageNum, pageSize);
        //分页查询数据
        page = sysLoginLogService.findLoginLogByPage(page, sysLoginLogQueryVo);
        return R.success(page);
    }
}
